<%@ page import="service.RainService" %>
<%@ page import="service.Impl.RainServiceImpl" %><%--
  Created by IntelliJ IDEA.
  User: 铃
  Date: 2024/9/18
  Time: 10:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    response.setContentType("text/html;charset=UTF-8");
    String contextpath= request.getContextPath();
    RainService rainService=new RainServiceImpl();
    String opr=request.getParameter("opr");



    if ("add".equals(opr)){
        String name=request.getParameter("name");
        String time=request.getParameter("time");
        int rain=Integer.parseInt(request.getParameter("rain"));
        String zhan=request.getParameter("zhan");
        String address=request.getParameter("address");
        int isadd=rainService.add(name,time,rain,zhan,address);
       if (isadd>0){
            application.setAttribute("isadd",isadd);
           out.print("<script>alert('新增成功!');location.href='"+contextpath+"/add.jsp'</script>");
           return;
       }else{
           application.setAttribute("isadd",isadd);
           out.print("<script>alert('添加失败!');location.href='"+contextpath+"/add.jsp'</script>");

       }

    }
%>
</body>
</html>
